home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c++
- Subject: Re: Newbie question on syntax of pointer to const
- Date: Wed, 31 Jan 1996 16:50:06 +0200
- Organization: Carelcomp Forest
- Message-ID: <310F819E.765B@cmt.lpr.mail.carel.fi>
- References: <4ej9eg$lq6@agate.berkeley.edu> <4ek468$jr1@clarknet.clark.net> <4ell6p$3f2q@yuma.ACNS.ColoState.EDU>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- Dave Steffen wrote:
- >
- >
- > What I'm curious about is the syntax of that second
- > line. Looking at Meyers' book, it looks like the const should come
- > after the *. In other words, are these the same:
- >
- > double const * pc;
- > double * const pc;
- >
- > The second syntax I've seen and used; the first I'm not sure
- > of (and am too lazy to check the DWP right now ;-)
- >
-
- 'double const *pc' defines a pointer to a constant double (eg. you cannot change
- the value pc is pointing to, but you can change the pc itself), 'double * const
- pc' defines a constant pointer to a double (cannot change the pc's value, but can
- change the value it's pointing to). The following, BTW, are identical (except for
- typographics...):
-
- double const * pc;
- const double * pc;
-
- Later,
- AriL
-
-
- --
- All my opinions are mine and mine alone.
-